/**
 * 
 */
package TestCases;

import junit.framework.TestCase;
import Tracer.RTVector;

/**
 * @author Peng Zhang
 * 
 */
public class RTVectorTest extends TestCase {

	private RTVector u;
	private RTVector v;
	private RTVector w;
	private RTVector s;

	/**
	 * @param name
	 */
	public RTVectorTest(String name) {
		super(name);
	}

	protected void setUp() throws Exception {

		u = new RTVector(3, 4, 5);
		v = new RTVector(4.5f, 2, (float) 2.5);
		w = new RTVector();
		new RTVector(u);
		s = new RTVector();
		s.setVector(3.5, 5, 7.5);
		super.setUp();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	/**
	 * Test method for testSetVector Test setVector after setting three vector
	 * values
	 */
	public void testSetVector() {
		RTVector testVector = new RTVector(3.5, 5, 7.5);
		s.setVector(3.5, 5, 7.5);
		assertTrue(s.isEqual(testVector));
	}

	/**
	 * Test method for dotProductVectors Test it works well after performing
	 * dotProductVector
	 */
	public void testDotProductVectors() {
		double dotp;
		dotp = RTVector.dotProductVectors(u, v);
		assertEquals("DotProduction Method is not correct !", dotp, 34.0);
	}

	/**
	 * Test method for crossProductVectors Test it works well after performing
	 * crossProductVectors
	 */
	public void testCrossProductVectors() {
		s = RTVector.crossProductVectors(u, v);
		RTVector testVector = new RTVector(0.0, 15.0, -12.0);
		assertTrue(s.isEqual(testVector));
	}

	/**
	 * Test method for sumVectors Test it works well after performing sumVectors
	 */
	public void testSumVectors() {
		w = RTVector.sumVectors(u, v);
		RTVector testVector = new RTVector(7.5, 6.0, 7.5);
		assertTrue(w.isEqual(testVector));
	}

	/**
	 * Test method for multipleVectors Test it works well after performing
	 * multipleVectors
	 */
	public void testMultipleVectors() {
		w = RTVector.multipleVectors(u, 2);
		RTVector testVector = new RTVector(6.0, 8.0, 10.0);
		assertTrue(w.isEqual(testVector));
	}

	/**
	 * Test method for calVectorLength Test it works well after performing
	 * calVectorLength
	 */
	public void testCalVectorLength() {
		double cal = RTVector.calVectorLength(u);
		assertEquals("CalVectorLength Method is not correct !", (float) cal,
				(float) 7.071068);
	}

	/**
	 * Test method for#normaliseVectors Test it works well after performing
	 * normaliseVectors
	 */
	public void testNormaliseVectors() {
		RTVector t = RTVector.normaliseVectors(u);
		RTVector testVector = new RTVector(0.4242640687119285,
				0.565685424949238, 0.7071067811865475);
		assertTrue(t.isEqual(testVector));
	}

	/**
	 * Test method for isEqual Test it works well after performing isEqual
	 */
	public void testIsEqual() {
		assertTrue(u.isEqual(new RTVector(3, 4, 5)));
	}
}
